<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>如果计算出最大可能数字之外的数字，则返回无穷大（Infinity）</title>
</head>

<body>
    <h1>JavaScript 数字</h1>
    <p>Infinity （或 -Infinity）是 JavaScript 在计算数时超出最大可能数范围时返回的值：</p>
    <p id="demo"></p>
    <script>
        var myNumber = 2;
        var txt = " ";
        while (myNumber != Infinity) {
            myNumber = myNumber * myNumber;
            txt = txt + myNumber + "<br>";
        }
        document.getElementById("demo").innerHTML = txt;
    </script>
</body>

</html>